<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
    <meta name="author" content="Coderthemes">
	
	<!-- jQuery  -->
    <script type="text/javascript" src="/static/plugins/jquery/jquery-3.6.0.min.js"></script>
	
	<!-- layui  -->
	<link rel="stylesheet" href="/static/plugins/layui/2.7.6/css/layui.css" media="all" />
	<script src="/static/plugins/layui/2.7.6/layui.js" charset="utf-8"></script>
	
	<link rel="stylesheet" href="/static/admin/css/mini-ease-edit.css">

	<!-- iconfont -->
	<link rel="stylesheet" href="/static/css/icon/iconfont.css" media="all" />
</head>
<body>

	<form class="layui-form" id="formId" method="post" action="/web/business/tpDeptUserPoint/addDeptUserPoint">
		<div class="layui-header layui-inline" style="margin-left: 10px;">
			<button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="formSubmit"><i class="iconfont icon-save"></i>保存</button>
		</div>
		<div class="layui-body">
			<!--第一行-->
			<div class="layui-form-item">
				<!--单号-->
				<div class="layui-inline layui-col-xs4 margin_r0">
					<div>
						<label class="layui-form-label">单号：</label>
						<div class="layui-input-block">
							<input type="text" name="bid" th:value="${dto.bid}" autocomplete="off"  readonly="readonly"  class="layui-input" lay-verify="required" >
						</div>
					</div>
				</div>
				<!--运营公司简称-->
				<div class="layui-inline layui-col-xs4 margin_r0">
					<div class="layui-col-xs4">
						<label class="layui-form-label"><font class="f_red">*</font>运营公司简称：</label>
					</div>
					<div class="layui-col-xs8">
						<select lay-search="" lay-filter="select-selectCompany">
							<option value="">请选择或搜索</option>
							<option th:each="item: ${dto.operateCompanyArr}" th:value="${item.vGsBm}" th:text="${item.vGsJc}"></option>
						</select>
					</div>
				</div>

				<!--运营公司编码-->
				<div class="layui-inline layui-col-xs4 margin_r0">
					<div>
						<label class="layui-form-label">运营公司编码：</label>
						<div class="layui-input-block">
							<input type="text" placeholder="请先选择运营公司简称" name="operateCompanyCode" id="operateCompanyCode" autocomplete="off"  readonly="readonly"  class="layui-input" lay-verify="required" >
						</div>
					</div>
				</div>
			</div>
			<!--第二行-->
			<div class="layui-form-item">
				<div class="layui-inline layui-col-xs4 margin_r0">
					<div>
						<label class="layui-form-label"><font class="f_red">*</font>评价类别：</label>
						<div class="layui-input-block">
							<input type="radio" name="pointType" th:each="pointType: ${dto.pointTypeArr}" th:value="${pointType.value}" th:title="${pointType.name}" lay-skin="primary" lay-filter="pointType" lay-verify="required">
						</div>
					</div>
				</div>
				<div class="layui-inline layui-col-xs4 margin_r0">
					<label class="layui-form-label"><font class="f_red">*</font>评价部门：</label>
					<div class="layui-input-block margin_l_90" style="display: flex;">
						<input type="text" id="organizationInfo" autocomplete="off" class="layui-input" value="" style="border: solid 0.1px; border-color: #B5B5B5; width:90%;" readonly="readonly">
						<i class="layui-icon layui-icon-close-fill" style="height: 30px; line-height: 30px;" title="清空此条件" onclick="this.previousSibling.previousSibling.value = '';this.previousSibling.previousSibling.previousSibling.previousSibling.value = '';"></i>
						<i style="position: relative; right: 40px; height: 30px; line-height: 30px;" class="layui-icon layui-icon-more" th:onclick="showModalSelectorOrg()"></i>
					</div>
				</div>
				<div class="layui-inline layui-col-xs4 margin_r0">
					<label class="layui-form-label">评价员工：</label>
					<div class="layui-input-block margin_l_90" style="display: flex;">
						<input type="text" id="pointUserInfo" autocomplete="off" class="layui-input" value="" style="border: solid 0.1px; border-color: #B5B5B5; width:90%;" readonly="readonly">
						<i class="layui-icon layui-icon-close-fill" style="height: 30px; line-height: 30px;" title="清空此条件" onclick="this.previousSibling.previousSibling.value = '';this.previousSibling.previousSibling.previousSibling.previousSibling.value = '';"></i>
						<i style="position: relative; right: 40px; height: 30px; line-height: 30px;" class="layui-icon layui-icon-more" th:onclick="showModalSelectorPointUser()"></i>
					</div>
				</div>

			</div>
			<!--第三行-->
			<div class="layui-form-item">
				<div class="layui-inline layui-col-xs12 margin_r0">
					<div>
						<label class="layui-form-label"><font class="f_red">*</font>评价事件：</label>
						<div class="layui-input-block">
							<input type="text" name="pointEvent" id="pointEvent" autocomplete="off"  class="layui-input" lay-verify="required" maxlength="50">
						</div>
					</div>
				</div>
			</div>
			<!--第四行-->
			<div class="layui-form-item">
				<div class="layui-inline layui-col-xs12 margin_r0">
					<div>
						<label class="layui-form-label">评价详情：</label>
						<div class="layui-input-block">
							<textarea name="pointDetail" id="pointDetail" placeholder="" class="layui-textarea" maxlength="1000"></textarea>
							<div><span id="textCount">0</span>/1000</div>
						</div>
					</div>
				</div>
			</div>
			<!--第五行-->
			<div class="layui-form-item">
				<!--制单人-->
				<div class="layui-inline layui-col-xs4 layui-col-sm7 layui-col-md8 margin_r0">
					<div>
						<label class="layui-form-label">制单人：</label>
						<div class="layui-input-block">
							<input type="text" name="createUserInfo" th:value="${dto.createUserInfo}" autocomplete="off"  readonly="readonly"  class="layui-input" lay-verify="required" >
						</div>
					</div>
				</div>
				<!--制单人-->
				<div class="layui-inline layui-col-xs4 margin_r0">
					<div>
						<label class="layui-form-label">制单人部门：</label>
						<div class="layui-input-block">
							<input type="text" name="creatUserDept" th:value="${dto.creatUserDept}" autocomplete="off"  readonly="readonly"  class="layui-input" lay-verify="required" >
						</div>
					</div>
				</div>
			</div>
			<!--隐藏域-->
			<input data-field-value="guidTsOrganizationInfo" type="hidden" name="pointDeptCode" id="pointDeptCode" value="">
			<input type="hidden" name="nodeLft" id="nodeLft" value="">
			<input type="hidden" name="nodeRgt" id="nodeRgt" value="">
			<input type="hidden" name="pointUserId" id="pointUserId" value="">
			<input type="hidden" name="selectCompanyUser" id="selectCompanyUser" value="">
			<input type="hidden" name="createUser" id="createUser" th:value="${dto.loginUserId}">

		</div>


		<!--
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"></fieldset>
		<div class="layui-form-item">
			<div class="layui-col-md1 layui-col-md-offset11">
				<div class="layui-btn-container">
					<button type="button" class="layui-btn" lay-submit lay-filter="formSubmit">保存</button>
				</div>
			</div>
		</div>
		-->
	</form>
	<script>
	$(function () {

		layui.use(['form', 'code'], function(){
			var form = layui.form;
			console.log('form',form);


			// 表单提交，共用同一个
			form.on('submit(formSubmit)', function(data){
				console.log('data',data);
				if(data.field.pointType ==undefined || data.field.pointType ==null ){
					layer.msg('请选择评价类别', {icon: 2});
					return ;
				}
				if(data.field.pointDeptCode ==undefined || data.field.pointDeptCode ==null || data.field.pointDeptCode =='' ){
					layer.msg('请选择评价部门', {icon: 2});
					return ;
				}
				var indexOfLoading = layer.load(1, {
					shade: [0.5,'#000000'] //0.1透明度的白色背景
				});

				$.post(data.form.action, data.field, function(res){
					if (res.code == 0) {
						layer.msg('操作成功');
						setTimeout(function(){
							//window.parent.location.reload();
							window.location.href = res.msg;
						}, 1000);
					} else {
						layer.close(indexOfLoading);
						layer.msg(res.msg);
					}
				});
				return false;
			});


			layui.code();
		});
	});
	layui.use(function(){
		var form = layui.form;
		var layer = layui.layer;
		// select 事件
		form.on('select(select-selectCompany)', function(data){
			//var elem = data.elem; // 获得 select 原始 DOM 对象
			var value = data.value; // 获得被选中的值
			//var othis = data.othis; // 获得 select 元素被替换后的 jQuery 对象
			$('#operateCompanyCode').val(value);

		});
	});
	function showModalSelectorOrg() {
		var w=($(window).width()*0.9);
		var h=($(window).height() - 50);
		layer.open({
			type: 2,
			area: [w+'px', h +'px'],
			fix: true,
			maxmin: false,
			shadeClose: true,
			shade:0.4,
			title: "选择",
			content: '/web/business/tpDeptUserPoint/toSelectorPointOrg'
		});
	}
	function showModalSelectorPointUser() {
		if($('#pointDeptCode').val()==null || $('#pointDeptCode').val()==''){
			layer.msg('请先选择要评价的部门!', {icon: 0});
			return;
		}
		var w=($(window).width()*0.9);
		var h=($(window).height() - 50);
		layer.open({
			type: 2,
			area: [w+'px', h +'px'],
			fix: true,
			maxmin: false,
			shadeClose: true,
			shade:0.4,
			title: "选择",
			content: '/web/business/tpDeptUserPoint/toSelectorPointUser?nodeLft='+$('#nodeLft').val() + '&nodeRgt=' + $('#nodeRgt').val()
		});
	}
	var el = document.getElementById('pointDetail');
	el.addEventListener('input',function () {
		var len =  txtCount(this); //   调用函数
		document.getElementById('textCount').innerHTML = len;
	});

	//函数 - 获取文本内容和长度
	function txtCount(el) {
		var val = el.value;
		var eLen = val.length;
		return eLen;
	}

	</script>

</body>
</html>
